#include <stdint.h>

/* Are we on a PC, important for validation, etc... */
#if (defined ( __i386__)||defined(__amd64__))
#define ON_PC 1
#else
#define ON_PC 0
#endif

/* TODO: offset_t is a 32-bit integer, which means this implementation will crash after 2^32 samples. */
typedef uint32_t offset_t;
typedef int16_t data_t;

#if (defined(__i386__)||defined(__amd64__))
#define POT "%u"
#else
#define POT "%lu"
#endif

#define BUFFER_BITS 8   /* Number of bits in the size of the buffer */
#define BUFFER_SIZE (1 << BUFFER_BITS)
#define BUFFER_MASK ((1 << BUFFER_BITS) - 1)
extern offset_t last_offset;

enum wave {
	qrs_wave,
	p_wave,
	t_wave,
	u_wave,
	MAX_WAVE
};

enum type {
	type_onset = 0,
	type_peak,
	type_end,
	type_sec_peak, /* Secondary peak */
	TYPE_MAX
};

#if ON_PC
void add_point(offset_t offset, enum wave wave, enum type type);
void dump_points(char* varname, enum wave wave, enum type type);
void dump_val();
void read_validation(char* filename, int offset);
void check_validation();
void set_lead(int i);
#else
void add_point(offset_t offset, enum wave wave, enum type type);
//static void dump_points(char* varname, enum wave wave, enum type type) {}
/*static void dump_val() {
	int i;
	fprintf(stderr, "dump_val: %d\n", pts_n);
	for (i = 0; i < pts_n; i++) {
		fprintf(stderr, "%d - %d\n", types[i], pts[i]);
	}
}*/
//static void read_validation(char* filename, int offset) {}
//static void check_validation() {}
#endif

#if ON_PC
#define data_printf(str, b...) printf(str, ##b)
//#define dbg_printf(str, b...) fprintf(stderr, str, ##b)
#define dbg_printf(str, b...) do {} while(0)
#define trace_printf(str, b...) do {} while(0)
#define trace_fun() do {} while(0)
#else
#define data_printf(str, b...) do {} while(0)
//#define dbg_printf(str, b...) do { putchar(START); printf(str, ##b); putchar(END); } while(0)
#define dbg_printf(str, b...) do {} while(0)
//#define trace_fun(str) do { putchar(START); printf("Function " __FUNCTION__ " - " str "\r\n"); putchar(END); } while(0)
//#define trace_printf(str, b...) do { putchar(START); printf(str, ##b); putchar(END); } while(0);
#define trace_fun(str, b...) do {} while(0)
#define trace_printf(str, b...) do {} while(0)
#endif
